var baseUrl="https://29858960.qcloud.la/"//beseurl
//var baseUrl="http://www.hucaicloud.com/"//beseurl
var UtilProperty=new Object;//所有作品的信息
//作品id
var workid;//作品id
var product_id;//产品id
var work_name="精装定制系列20p";//作品名称
var sku_code="C1363";//商品的skuid
var ctxmsg = new Object;//存储正在执行旋转 替换  操作的信息
var ctxtext = new Object;//存储正在执行 编辑文字 操作   控件的信息
var user_id,token;
var boxwindthheight=new Object;//绘图区域的大小
boxwindthheight.width=$(window).width()-24;
boxwindthheight.height=$(window).height()-261;
var  maxScreen=new Object;//绘制的大图大小
maxScreen.width=$(window).width()*0.8;
maxScreen.height=$(window).height()*0.8;

var imgsize=400;//固定获取的图片宽
//var skucodebuy=['C1494','C1495','C1496','C1497', 'C0037','C0349','C1499'];//出现现在去购买的按钮
var skucodebuy={
	'C1494':'https://h5.youzan.com/v2/goods/1yk0snee0bgz1?reft=1511936748178&spm=f46452435',
	'C1495':'https://h5.youzan.com/v2/goods/1yk0snee0bgz1?reft=1511936748178&spm=f46452435',
	'C1496':'https://h5.youzan.com/v2/goods/3eo35tyw7i299?reft=1511936836503&spm=f46452435',
	'C1497':'https://h5.youzan.com/v2/goods/3eo35tyw7i299?reft=1511936836503&spm=f46452435',
	'C0037':'https://h5.youzan.com/v2/goods/1ya6e3md2e48d?reft=1511936897940&spm=f46452435',
	'C0349':'https://h5.youzan.com/v2/goods/1ya6e3md2e48d?reft=1511936897940&spm=f46452435',
	'C1499':'https://h5.youzan.com/v2/goods/1ya6e3md2e48d?reft=1511936897940&spm=f46452435',
	};//出现现在去购买的按钮

var album_wid=($(window).width()-24-27)/2-24;//作品列表的宽
var Pixel_Ratio;//获取当前设备的设备像素比

//获取当前设备的设备像素比
initPixelRatio();

// lym 2018.01.03 修改 图片加载 原先的的id标志转为url标志
UtilProperty.background=new Object;//背景
UtilProperty.background.backgroundimage=new Object;
UtilProperty.background.backgroundinfo=new Array;

var bgsize_str=boxwindthheight.width+"x"+boxwindthheight.height;// 背景图片链接后所带的参数
var imgwid=boxwindthheight.width>boxwindthheight.height?boxwindthheight.height:boxwindthheight.width;
var imgsize_str=imgwid<imgsize?(imgsize+'x'+imgsize):(imgwid+'x'+imgwid);// 图片链接后所带的参数



function baseAjax(urlstr,type,obj,fn)//基本的接口访问
{
	
	$.ajax({ 
			  		
		url:baseUrl+urlstr,	
		type:type,
		dataType:"json",		
		data:obj,		
        success:function(data){
        	if(data.code!=200){ 
				 dialogshow("提示",data.description);
				 if(!$("#loadtoast").is(":hidden")){
				 	$("#loadtoast").hide();
				 }
			}else{
				fn(data);
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){	
				if(XMLHttpRequest.status==0){
					dialogshow("提示",'加载失败，请重新加载！');
					 if(!$("#loadtoast").is(":hidden")){
				 	$("#loadtoast").hide();
					 }
				}else{
					dialogshow("提示",XMLHttpRequest.status);	
				}
							
		}
    });
  
	
}
function dialogshow(title,context){
	$("#diatips").find(".weui-dialog__title").html(title);
	$("#diatips").find(".weui-dialog__bd").html(context);	
	$("#diatips,.weui-mask").show();
}

function diatipshide(a){
	$("#diatips").find(".weui-dialog__title").html("");
	$("#diatips").find(".weui-dialog__bd").html("");	
	$("#diatips,.weui-mask").hide();
	if($("#diatips").attr("checklogin")){
		window.location.href=baseUrl+'wechat/login';
		$("#diatips").removeAttr("checklogin");
		 $("#loadtoast .weui-mask_transparent").show();
	}
	if($('.isyes').attr("oper")=="changelayout"){
		$('.layoutcon').fadeOut()
		$(".layoutbox").animate({bottom: '-100%'}, "slow");
		$('.isyes').removeAttr("oper").removeAttr("pageno").removeAttr("index");
		$('.isyes').removeClass("primary").addClass("default").removeAttr().hide();
		$(".iscancel").text("确定").removeClass("default").addClass("primary");
	}
	if($('.iscancel').attr("submitalbum")=="yes"){
		$(".myphotoalbum").show();
		$(".submitalbum").hide();
		$('.iscancel').removeAttr("submitalbum");
		
	}
	
	if($('.isyes').attr("oper")=="deletework"){
		$('.iscancel').removeAttr("oper").removeAttr("work_id").removeAttr("index");
		$('.isyes').removeClass("primary").addClass("default").removeAttr().hide();
		$(".iscancel").text("确定").removeClass("default").addClass("primary");
	}
}

function GetRequest() {  

		   var url = location.search; //获取url中"?"符后的字串
   		   var theRequest = new Object();
	   if (url.indexOf("?")!= -1) {
	      var str = url.substr(1);
	      strs = str.split("&");
		      for(var i = 0; i < strs.length; i ++) {
		         theRequest[strs[i].split("=")[0]]=strs[i].split("=")[1];
		      }
		 }   
   		return theRequest;
	} 
	

//获取当前设备的设备像素比
function initPixelRatio() {
    var canvas = document.createElement('canvas');
    var ctx = canvas.getContext('2d');

    // polyfill 提供了这个方法用来获取设备的 pixel ratio
    var getPixelRatio = function(context) {
        var backingStore = context.backingStorePixelRatio ||
            context.webkitBackingStorePixelRatio ||
            context.mozBackingStorePixelRatio ||
            context.msBackingStorePixelRatio ||
            context.oBackingStorePixelRatio ||
            context.backingStorePixelRatio || 1;
    
        return (window.devicePixelRatio || 1) / backingStore;
    };

    Pixel_Ratio = getPixelRatio(ctx);
    
   boxwindthheight.width *= Pixel_Ratio;   
   boxwindthheight.height *= Pixel_Ratio;
   maxScreen.width *= Pixel_Ratio;   
   maxScreen.height *= Pixel_Ratio;
    // 注意，这里的 width 和 height 变成了 width * ratio 和 height * ratio
    //ctx.drawImage(document.querySelector('img'), 0, 0, 300 * ratio, 90 * ratio);
    
     bgsize_str=boxwindthheight.width+"x"+boxwindthheight.height;// 背景图片链接后所带的参数
 	imgwid=boxwindthheight.width>boxwindthheight.height?boxwindthheight.height:boxwindthheight.width;
 	imgsize_str=imgwid<imgsize?(imgsize+'x'+imgsize):(imgwid+'x'+imgwid);// 图片链接后所带的参数

}

